<?php
// 取该p_id对应的商品图片
$pid = $_REQUEST['pid'];
$conn = mysqli_connect("localhost:3306","root","","php");
mysqli_query( $conn, 'set names utf8' );
$sql = "select p_image from product where p_id = $pid";
$result = mysqli_query( $conn, $sql );
if ( $result ) {
    if( $row = mysqli_fetch_assoc($result) ){
        header("Content-Type: image");
        echo $row["p_image"];
    }
}
mysqli_close( $conn );
?>